//
//  SignInAbnormalViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/15.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "SignInAbnormalViewController.h"
#import "CauseListModel.h"
#import "BasicCenterTableViewCell.h"


#define getCauseList @"getCauseList"//异常信息
#define postAbnormalPunchInfo @"postAbnormalPunchInfo"//异常打卡申请
#define postCommitDealInfo @"postCommitDealInfo"//确认提交信息
#define getAbnormalPunchInfo @"getAbnormalPunchInfo"
@interface SignInAbnormalViewController ()

@property (nonatomic,strong) UITableView *abnormalTableView;
@property (nonatomic,strong) CauseListModel *causeListModel;//异常model
@property (nonatomic,strong) UILabel *realityLabel;//实际打卡时间
@property (nonatomic,strong) UILabel *realityTitleLabel;//实际打卡时间title
@property (nonatomic,strong) UILabel *abnormalLabel;//异常描述
@property (nonatomic,strong) UILabel *abnormalTitleLabel;//异常描述
@property (nonatomic,strong) UILabel *signLabel;//异常描述个数
@property (nonatomic,strong) NSString *realTimeStr;//实际时间
@property (nonatomic,strong) NSString *abnormalDescription;//异常信息id
@property (nonatomic,strong) NSString *realTime;
@property (nonatomic,strong) NSString *attendanceDate;
@property (nonatomic,strong) NSString *causa;
@property (nonatomic,strong) NSString *describeName;
@end

@implementation SignInAbnormalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationTitle:self.navaTitle];
    [self getDropListRequestWithdataSwith:@"4" isDetailList:NO];
    if (self.vacateBillId) {
        [self setNavigationTitle:@"考勤异常说明"];
        
    }
    //[self getCauseListRequest];
    // Do any additional setup after loading the view.
}

#pragma mark -初始化数据
- (void)dataInit{
    self.businessCode=@"YC0012";
    self.mustSelectArr=[NSMutableArray new];
    self.addWorkPersonArr=[NSMutableArray new];
    NSDateFormatter *formatter=[NSDateFormatter new];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *dateStr=[formatter stringFromDate:[NSDate date]];
    _titleArr=@[@"申  请  人 :",@"考勤日期 :",@"异常描述 :",@"实际打卡时间 :"];
    _messageArr=[NSMutableArray arrayWithArray:@[[LZXHelper getUserName],dateStr,@"请选择~",@"请选择~"]];
}

#pragma mark -键盘退出的通知事件
- (void)keyboardWillHide:(NSNotification *)aNotification
{
    //    //获取键盘高度
    //    NSDictionary *userInfo = [aNotification userInfo];
    //    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    //    CGRect keyboardRect = [aValue CGRectValue];
    //    CGFloat height = keyboardRect.size.height;
    
    //    [UIView animateWithDuration:0.3 animations:^{
    //        _backMsgView.y=IPHONE_HEIGHT-51;
    //    }];
    _tableView.height=IPHONE_HEIGHT-64;
    [self removeTapGestureRecognizer];
    //_tableView.y=64;
    
}

#pragma mark — creatView
- (void)creatView{
    
    //创建列表
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT-64) style:UITableViewStyleGrouped];
    //_myTableView.backgroundColor=[UIColor redColor];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.tag=110;
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.showsVerticalScrollIndicator=NO;
    _tableView.showsHorizontalScrollIndicator=NO;
    _tableView.bounces=NO;
    //[self addTableViewUpdateRefresh:_tableView BindingIdentity:@""];
    //    [self addTableViewLoadMoreData:_tableView BindingIdentity:@""];
    [self.view addSubview:_tableView];
    [self addTableViewFootView];
}


//返回上一页
- (void)backClick{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)addTableViewFootView{
    //添加提交button
    UIView *footView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 80)];
    footView.backgroundColor=[UIColor clearColor];
    
    NSArray *title=@[@"确定"];
    CGFloat buttonWidth=(IPHONE_WIDTH-(title.count+1)*10)/title.count;
    for (int i=0; i<title.count; i++) {
        UIButton *submitButton=[MyControl creatButtonWithFrame:CGRectMake(10*(i+1)+buttonWidth*i,20, buttonWidth, 40) target:self sel:@selector(submitClick:) tag:120+i image:nil title:title[i]];
        submitButton.layer.masksToBounds=YES;
        submitButton.layer.cornerRadius=5;
        [submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        if (i==0) {
            submitButton.backgroundColor=COLOR_MIDBLUE;
        }else{
            submitButton.backgroundColor=[UIColor orangeColor];
        }
        [footView addSubview:submitButton];
    }
    _tableView.tableFooterView=footView;
}

- (void)submitClick:(UIButton *)button{
    [self.view endEditing:YES];
    [LZXHelper postAlertViewControllerWithTitle:@"确认申请吗?" message:nil cancelButtonTitle:@"取消" otherButtonTitle:@"确定" cancelEvent:^{
        
    } otherEvent:^{
            [self postAbnormalPunchInfoRequest];
    } viewController:self];
}

#pragma mark - 异常listView
- (void)creatAbnormalListView{
    if (_abnormalTableView) {
        [_abnormalTableView removeFromSuperview];
        _abnormalTableView=nil;
    }
    //[self addTapGestureRecognizerWithView:_tableView];
    CGFloat height=44;
    if (self.dropListModel.dataArr.count<5) {
        height=44*self.dropListModel.dataArr.count;
    }else{
        height=44*5;
    }
    _abnormalTableView=[[UITableView alloc]initWithFrame:CGRectMake(105, 106+80, IPHONE_WIDTH-105-10, height) style:UITableViewStylePlain];
    _abnormalTableView.delegate=self;
    _abnormalTableView.dataSource=self;
    _abnormalTableView.tag=111;
    _abnormalTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _abnormalTableView.showsVerticalScrollIndicator=NO;
    _abnormalTableView.showsHorizontalScrollIndicator=NO;
    _abnormalTableView.bounces=NO;
    [self.view addSubview:_abnormalTableView];
}
#pragma mark -textViewDelegate

- (void)textViewDidBeginEditing:(UITextView *)textView{
    //滚动输入框 避免被键盘遮挡
    [self addTapGestureRecognizer];
    [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor clearColor]];
    NSIndexPath* path = [NSIndexPath indexPathForRow:0 inSection:1];
    [self performSelector:@selector(scrollToCell:) withObject:path afterDelay:0];
    if (_abnormalTableView) {
        [_abnormalTableView removeFromSuperview];
        _abnormalTableView=nil;
    }
}


#pragma mark-将textView默认文字设置为提示文字
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
    [self removeTapGestureRecognizer];
    return YES;
}

#pragma mark -手势的响应事件
- (void)tapGestureClick{
    [self.view endEditing:YES];
    if (_abnormalTableView) {
        [_abnormalTableView removeFromSuperview];
        _abnormalTableView=nil;
    }
}
//#pragma mark -避免键盘遮挡
//- (void)textViewDidBeginEditing:(UITextView *)textView{
//    [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor clearColor]];
//    NSIndexPath* path = [NSIndexPath indexPathForRow:textView.tag-200 inSection:0];
//    [self performSelector:@selector(scrollToCell:) withObject:path afterDelay:0];
//}

-(void) scrollToCell:(NSIndexPath*) path {
    [_tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
}


#pragma mark - TableViewDelagate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if (tableView.tag==111) {
        return 1;
    }
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (tableView.tag==111) {
        return self.dropListModel.dataArr.count;
    }else{
        if (section==0) {
            return _titleArr.count;
        }
        return 1;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (tableView.tag==111) {
        NSString *cellID=@"UITableViewCell";
        BasicCenterTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell=[[BasicCenterTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;

        }
        DutyDropModel *mode=self.dropListModel.dataArr[indexPath.row];
        cell.myTitle.text=mode.keyword;
        return cell;
    }else{
        if (indexPath.section==0) {
            NSString *cellID=@"DutyBasicTableViewCell";
            DutyBasicTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[DutyBasicTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                if (indexPath.row==2) {
                    _signLabel=[MyControl creatLabelWithFrame:CGRectMake(IPHONE_WIDTH-30, 15, 20, 20) text:@""];
                    _signLabel.backgroundColor=[UIColor redColor];
                    _signLabel.textColor=[UIColor whiteColor];
                    _signLabel.layer.masksToBounds=YES;
                    _signLabel.layer.cornerRadius=_signLabel.width/2;
                    _signLabel.hidden=YES;
                    _signLabel.font=FONT_12;
                    _signLabel.textAlignment=NSTextAlignmentCenter;
                    [cell.contentView addSubview:_signLabel];
                }
            }
            cell.myTitleLabel.text=_titleArr[indexPath.row];
            cell.messageLabel.text=_messageArr[indexPath.row];
            //实际打卡
            if (indexPath.row==3) {
                cell.arrowImageView.hidden=NO;
                cell.myTitleLabel.width=110;
                self.realityTitleLabel=cell.myTitleLabel;
                self.realityLabel=cell.messageLabel;
                cell.messageLabel.x=cell.myTitleLabel.x+cell.myTitleLabel.width+5;
                cell.messageLabel.width=IPHONE_WIDTH-(cell.myTitleLabel.x+cell.myTitleLabel.width+5);
                if ([cell.messageLabel.text isEqualToString:@"请选择~"]) {
                    cell.messageLabel.textColor=[UIColor lightGrayColor];
                }else{
                    cell.messageLabel.textColor=[UIColor blackColor];
                }
            }
            if (indexPath.row==2) {
                if ([_messageArr[indexPath.row] isEqualToString:@"请选择~"]) {
                    cell.messageLabel.textColor=[UIColor lightGrayColor];   
                }else{
                    cell.messageLabel.textColor=[UIColor blackColor];
                }
                self.abnormalLabel=cell.messageLabel;
            }
            return cell;
            //原因
        }else{
            NSString *cellID=@"ReasonTextTableViewCell";
            ReasonTextTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
            if (!cell) {
                cell=[[ReasonTextTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID title:@" 请输入事由 : " noticeStr:nil];
                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                self.reasonTextView=cell.reasonTextView;
                self.reasonTextView.delegate=self;
                self.reasonTitleLabel=cell.myTitleLabel;
            }
            cell.reasonTextView.text=self.causa?self.causa:@"";
            return cell;
        }
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.reasonTextView resignFirstResponder];
    if (tableView.tag==111) {
        
        //移除手势
        //[self removeTapGestureRecognizer];
        //填充选择的异常信息
        DutyDropModel *model=self.dropListModel.dataArr[indexPath.row];
        _abnormalLabel.text=[model.keyword copy];
        _abnormalLabel.textColor=[UIColor blackColor];
        _abnormalDescription=[model.keywordId copy];
        //切割
        NSArray *infoArr=[model.keyValue componentsSeparatedByString:@"|"];
        if (infoArr.count>0) {
            self.keywordId=infoArr[0];
        }
        if (infoArr.count>1) {
            if ([infoArr[1] isEqualToString:@"1"]) {
                if (_titleArr.count==4) {
                    _titleArr=@[@"申  请  人 :",@"考勤日期 :",@"异常描述 :"];
                    [_tableView reloadData];
                }
            }
        }else{
            if (_titleArr.count<4) {
                _titleArr=@[@"申  请  人 :",@"考勤日期 :",@"异常描述 :",@"实际打卡时间 :"];
                [_tableView reloadData];
            }
        }
        [_messageArr replaceObjectAtIndex:2 withObject:[model.keyword copy]];
        //移除选择列表
        if (_abnormalTableView) {
            [_abnormalTableView removeFromSuperview];
            _abnormalTableView=nil;
        }
    }else{
        if (indexPath.row==3&&indexPath.section==0) {
            [self setLabelBorderColorWithLabel:self.realityTitleLabel color:[UIColor clearColor]];
            if (_abnormalTableView) {
                [_abnormalTableView removeFromSuperview];
                _abnormalTableView=nil;
            }
            DatePickerView *datePickerView=[[DatePickerView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT)nowDateStr:nil];
            __weak NSMutableArray *myMessageArr=_messageArr;
//            __weak UITableView *myTableView=_tableView;
            __weak SignInAbnormalViewController *mySelf=self;
            datePickerView.sureBlock=^(NSString *timeStr){
                if (![_abnormalLabel.text isEqualToString:@"请选择~"]) {
                    if (_abnormalLabel.text.length) {
                        NSString *dateStr=[_abnormalLabel.text substringToIndex:10];
                        if ([dateStr isEqualToString:[timeStr substringToIndex:10]]) {
                            mySelf.realityLabel.text=[timeStr copy];
                            mySelf.realityLabel.textColor=[UIColor blackColor];
                            mySelf.realTimeStr=[timeStr copy];
                            [myMessageArr replaceObjectAtIndex:3 withObject:timeStr];
                        }else{
                            [LZXHelper postMessageWithText:@"异常日期和实际日期必须相同!" View:self.view];
                        }
                    }
                }
            };
            [[[UIApplication sharedApplication].delegate window] addSubview:datePickerView];
        }else if (indexPath.row==2&&indexPath.section==0){
            if (!self.vacateBillId) {
                [self setLabelBorderColorWithLabel:self.abnormalTitleLabel color:[UIColor clearColor]];
                //如果有异常信息才显示
                if (self.dropListModel.dataArr.count>0) {
                    if (_abnormalTableView) {
                        [_abnormalTableView removeFromSuperview];
                        _abnormalTableView=nil;
                    }else{
                        [self creatAbnormalListView];
                    }
                }
            }
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView.tag==111) {
        return 44;
    }
    if (indexPath.section==1) {
        return 100;
    }
    return 50;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}



- (void)getCauseListRequest{
    
    NSDictionary *dict=@{
                         @"businessCode":self.businessCode?self.businessCode:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getCauseList soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        self.causeListModel=[[CauseListModel alloc]initWithResponse:responseObject];
        if ([self.causeListModel.code isEqualToString:@"200"]) {

        }else if([self.causeListModel.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:self.causeListModel.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -异常打卡申请

- (void)postAbnormalPunchInfoRequest{
    if ([self.abnormalLabel.text isEqualToString:@"请选择~"]) {
        [self setLabelBorderColorWithLabel:self.abnormalTitleLabel color:[UIColor redColor]];
        [LZXHelper postMessageWithText:@"请选择异常描述!" View:self.view];
        return;
    }
    
    if ([self.realityLabel.text isEqualToString:@"请选择~"]) {
        [self setLabelBorderColorWithLabel:self.realityTitleLabel color:[UIColor redColor]];
        [LZXHelper postMessageWithText:@"实际打卡时间不能为空!" View:self.view];
        return;
    }
    
    if (self.reasonTextView.text.length==0&&self.causa==nil) {
        [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor redColor]];
        [LZXHelper postMessageWithText:@"考勤事由不能为空!" View:self.view];
        return;
    }
    
    //转换时间格式
    NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSDate *date=[formatter dateFromString:self.realTimeStr];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    //现在时间
    if (!self.applyStr) {
        self.applyStr=[formatter stringFromDate:date];
    }
    if (!self.attendanceDate) {
       self.attendanceDate=self.abnormalLabel.text;
    }
    if (!self.causa) {
        self.causa=self.reasonTextView.text;
    }
    
    //{"abnormalDescription":"6124","applyTime":"2016-12-01 19:01:36","attendanceDate":"2016-12-01 19:01:36","cardInfoId":"26734","causa":"下班忘记打卡了。","id":"","infoId":"0","realTime":""}
    NSDictionary *dict=@{
                          @"abnormalDescription":_abnormalDescription?_abnormalDescription:@"",
                          @"applyTime":self.applyStr?self.applyStr:@"",
                          @"attendanceDate":self.attendanceDate?self.attendanceDate:@"",
                          @"causa":self.causa?self.causa:@"",
                          @"id":self.vacateBillId?self.vacateBillId:@"",
                          @"infoId":self.infoId?self.infoId:@"",
                          @"realTime":self.realTime?self.realTime:@"",
                          @"cardInfoId":self.cardInfoId?self.cardInfoId:@"",
                          @"SignDrId":self.abnormalDescription?self.abnormalDescription:@""
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postAbnormalPunchInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"220"]) {
//            NSDictionary *dataDict=responseObject[@"retContent"];
//            NSString *isCanCommit=dataDict[@"isCanCommit"];
//            if ([isCanCommit isEqualToString:@"1"]) {
//                [LZXHelper postAlertViewControllerWithTitle:@"确定要提交吗?" message:nil cancelButtonTitle:@"取消" otherButtonTitle:@"确定" cancelEvent:^{
//                    
//                } otherEvent:^{
//                    [self postCommitDealInfoRequestWithResponObject:responseObject];
//                } viewController:self];
//            }
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            if (self.vacateBillId) {
                for (UIViewController *controller in self.navigationController.viewControllers) {
                    if ([controller isKindOfClass:[MyJobListViewController class]]) {
                        [self.navigationController popToViewController:controller animated:YES];
                    }
                }
            }else{
                [self.navigationController popViewControllerAnimated:YES];
            }
        }else if([model.code isEqualToString:@"200"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}


#pragma mark -确认提交

- (void)postCommitDealInfoRequestWithResponObject:(id)responObject{
    NSDictionary *dataDict=responObject[@"retContent"];
    NSString *ids=dataDict[@"id"];
    NSString *infoId=dataDict[@"infoId"];
    
    NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *timeStr=[formatter stringFromDate:[NSDate date]];
    NSDictionary *dict=@{
                         @"dealSwitch":@"yc",
                         @"infoId":infoId?infoId:@"",
                         @"rules":@"",
                         @"serviceTime":self.serviceTime?self.serviceTime:timeStr,
                         @"vacateBillId":ids?ids:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postCommitDealInfo soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            if (self.vacateBillId) {
                for (UIViewController *controller in self.navigationController.viewControllers) {
                    if ([controller isKindOfClass:[MyJobListViewController class]]) {
                        [self.navigationController popToViewController:controller animated:YES];
                    }
                }
            }else{
                [self.navigationController popViewControllerAnimated:YES];
            }
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}

- (void)dropListModelRequestSuccess{
    if (self.dropListModel.dataArr.count>0) {
        _signLabel.hidden=NO;
        _signLabel.text=[NSString stringWithFormat:@"%ld",self.dropListModel.dataArr.count];
    }
    if (self.vacateBillId) {
        [self getAbnormalPunchInfoRequest];
    }
}


- (void)getAbnormalPunchInfoRequest{
    
    //    if (self.reasonTextView.text.length==0) {
    //        [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor redColor]];
    //        [LZXHelper postMessageWithText:@"考勤事由不能为空!" View:self.view];
    //        return;
    //    }
    
    NSDictionary *dict=@{
                         @"businessCode":self.businessCode?self.businessCode:@"",
                         @"vacateBillId":self.vacateBillId?self.vacateBillId:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getAbnormalPunchInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            
            NSDictionary *dataDict=responseObject[@"retContent"];
            self.abnormalDescription=dataDict[@"abnormalDescription"];;
            self.realTime=dataDict[@"realTime"];;
            self.attendanceDate=dataDict[@"attendanceDate"];;
            self.causa=dataDict[@"causa"];;
            self.describeName=dataDict[@"describeName"];
            [_messageArr replaceObjectAtIndex:1 withObject:self.attendanceDate];
            [_messageArr replaceObjectAtIndex:2 withObject:self.describeName];
            [_tableView reloadData];
            for (DutyDropModel *dropmodel in self.dropListModel.dataArr) {
                if ([dropmodel.keyword isEqualToString:self.describeName]) {
                    _abnormalDescription=dropmodel.keywordId;
                    //切割
                    NSArray *infoArr=[dropmodel.keyValue componentsSeparatedByString:@"|"];
                    if (infoArr.count>0) {
                        self.keywordId=infoArr[0];
                    }
                    if (infoArr.count>1) {
                        if (_titleArr.count==4) {
                            _titleArr=@[@"申  请  人 :",@"考勤日期 :",@"异常描述 :"];
                            [_tableView reloadData];
                        }
                    }else{
                        if (_titleArr.count<4) {
                            _titleArr=@[@"申  请  人 :",@"考勤日期 :",@"异常描述 :",@"实际打卡时间 :"];
                            [_tableView reloadData];
                        }
                    }
                    break;
                }
            }
            
            // self.otherDayLabel.text=se
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}

- (void)getVacateInfoRequestWithVacateBillId:(NSString *)vacateBillId{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
